import React, { useState } from 'react'
import { Card, Button, Table, Tag, Modal, Form, Input, Select, DatePicker } from "antd"
import { PlusOutlined } from '@ant-design/icons';
import dayjs from 'dayjs';
import OaPagination from '@/components/OaPagination';
import OaBreadcrumb from '@/components/OaBreadcrumb';

const { Option } = Select;
const { RangePicker } = DatePicker;
const dateFormat = 'YYYY/MM/DD';
const columns = [
    {
        title: '标题',
        dataIndex: 'name',
        key: 'name'
    },
    {
        title: '类型',
        dataIndex: 'age',
        key: 'age',
    },
    {
        title: '原因',
        dataIndex: 'address',
        key: 'address',
    }, {
        title: '发起时间',
        dataIndex: 'address',
        key: 'address',
    },
    {
        title: '开始日期',
        dataIndex: 'address',
        key: 'address',
    },
    {
        title: '结束日期',
        dataIndex: 'address',
        key: 'address',
    },
    {
        title: '审核领导',
        dataIndex: 'address',
        key: 'address',
    },
    {
        title: '反馈意见',
        dataIndex: 'address',
        key: 'address',
    },
    {
        title: '审核状态',
        key: 'action',
        render: (_, record) => (
            <Tag>审核中</Tag>
        ),
    },
];

const data = [
    {
        key: '1',
        name: 'John Brown',
        age: 32,
        address: 'New York No. 1 Lake Park',
        tags: ['nice', 'developer'],
    },
    {
        key: '2',
        name: 'Jim Green',
        age: 42,
        address: 'London No. 1 Lake Park',
        tags: ['loser'],
    },
    {
        key: '3',
        name: 'Joe Black',
        age: 32,
        address: 'Sydney No. 1 Lake Park',
        tags: ['cool', 'teacher'],
    },
];

export default function MyAbsent() {
    const [isModalOpen, setIsModalOpen] = useState(false);
    const showModal = () => {
        setIsModalOpen(true);
    };
    const handleOk = () => {
        setIsModalOpen(false);
    };
    const handleCancel = () => {
        setIsModalOpen(false);
    };

    const onFinish = (values) => {
        console.log('Success:', values);
    };
    const onFinishFailed = (errorInfo) => {
        console.log('Failed:', errorInfo);
    };
    return (
        <div>
            <OaBreadcrumb></OaBreadcrumb>
            <Card style={{ display: 'flex', justifyContent: 'right' }}>
                <Button type="primary" icon={<PlusOutlined />} onClick={showModal}>
                    发起考勤
                </Button>
            </Card>
            <Card style={{ marginTop: '20px' }}>
                <Table columns={columns} dataSource={data} pagination={false} bordered />
            </Card>

            <OaPagination></OaPagination>

            <Modal title="发起请假" open={isModalOpen} onOk={handleOk} onCancel={handleCancel}>
                <Form
                    name="basic"
                    labelCol={{
                        span: 6,
                    }}
                    wrapperCol={{
                        span: 18,
                    }}
                    style={{
                        maxWidth: 600,
                    }}
                    initialValues={{
                        remember: true,
                    }}
                    onFinish={onFinish}
                    onFinishFailed={onFinishFailed}
                    autoComplete="off"
                >
                    <Form.Item label="标题" name="title" rules={[{ required: true, message: '请输入请假标题!' }]}>
                        <Input />
                    </Form.Item>
                    <Form.Item label="请假类型" name="type" rules={[{ required: true, message: '请选择请假类型' }]}>
                        <Select placeholder="请选择请假类型">
                            <Option value="male">Male</Option>
                            <Option value="female">Female</Option>
                            <Option value="other">Other</Option>
                        </Select>
                    </Form.Item>
                    <Form.Item label="请假时间" name="time" rules={[{ required: true, message: '请选择请假时间!' }]}>
                        <RangePicker
                            defaultValue={[dayjs('2015/01/01', dateFormat), dayjs('2015/01/01', dateFormat)]}
                            format={dateFormat}
                        />
                    </Form.Item>
                    <Form.Item label="审批领导" name="leader">
                        <Input disabled />
                    </Form.Item>
                    <Form.Item label="请假理由" name="password" rules={[{ required: true, message: '请输入请假理由!' }]}>
                        <Input.TextArea showCount maxLength={100} />
                    </Form.Item>
                </Form>
            </Modal>
        </div>
    )
}
